//
//  LanguageSettingCellModel.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/29.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "LanguageSettingCellModel.h"

@implementation LanguageSettingCellModel

- (void)setLanguageType:(BCLanguageType)languageType {
    _languageType = languageType;
    //
    BCLanguageType currentType = [BCLabguageSettingManager shared].appLanguage;
    //
    self.isCurrent = (currentType==languageType);
}


+ (NSMutableArray *)languageSource {
    NSMutableArray *source = [NSMutableArray array];
    //
    [source addObject:[self english]];
    [source addObject:[self chineseSimplified]];
    [source addObject:[self chineseTraditional]];
//    [source addObject:[self japanese]];
    //
    LanguageSettingCellModel *current;
    for (LanguageSettingCellModel *model in source) {
        if (model.isCurrent) {
            current = model;
            break;
        }
    }
    if (current) {
        NSInteger idx = [source indexOfObject:current];
        //
        if (idx!=0) {
            [source removeObject:current];
            [source insertObject:current atIndex:0];
        }
    }
    
    return source;
}


//英文
+ (LanguageSettingCellModel *)english {
    LanguageSettingCellModel *model = [LanguageSettingCellModel new];
    model.originalLanguageString = @"English";
    model.localLanguageString = BCLocalizedKey(@"English");
    model.languageType = BCLanguageTypeEnglish;
    return model;
}
//简体中文
+ (LanguageSettingCellModel *)chineseSimplified {
    LanguageSettingCellModel *model = [LanguageSettingCellModel new];
    model.originalLanguageString = @"简体中文";
    model.localLanguageString = BCLocalizedKey(@"Chinese Simplified");
    model.languageType = BCLanguageTypeChineseSimplified;
    return model;
}
//繁體中文
+ (LanguageSettingCellModel *)chineseTraditional {
    LanguageSettingCellModel *model = [LanguageSettingCellModel new];
    model.originalLanguageString = @"繁體中文";
    model.localLanguageString = BCLocalizedKey(@"Chinese Traditional");
    model.languageType = BCLanguageTypeChineseTraditional;
    return model;
}
//日文
+ (LanguageSettingCellModel *)japanese {
    LanguageSettingCellModel *model = [LanguageSettingCellModel new];
    model.originalLanguageString = @"日本語";
    model.localLanguageString = BCLocalizedKey(@"Japanese");
    model.languageType = BCLanguageTypeJapanese;
    return model;
}

@end
